﻿using GameData.Domains.Mod;
using GameData.GameDataBridge;
using GylCSharpUtils.Common.Utils;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using TaiwuModdingLib.Core.Plugin;
using TaiwuModFramework.Common;
using TaiwuModFramework.Common.Abstract;
using TaiwuModFramework.Common.Base;
using TaiwuModFramework.Common.Info;
using TaiwuModFramework.Common.Manager;

namespace TaiwuModFramework.Frontend {

    [PluginConfig("太吾MOD框架", "gyl", "1.0.0")]
    public class FrontendEntrance : TaiwuRemakeHarmonyPlugin {

        private static ALogger Log { get { return FwDomain.Log; } }

        public override void Dispose() {
            
        }

        public override void Initialize() {
            if(FwDomain.ModIdStr != null) return;
            FwDomain.ClearLog(); // 清除Default.log的内容
            // 初始化框架域
            FwDomain.Init(ModIdStr);
            // 尝试清除之前backend.log日志文件内的内容
            FwDomain.ClearLog();
            // 注册组件
            PluginEntrance.AddPlugin(this.ModIdStr, this.PluginName, new CompConfig());
            
        }


        public override void OnModSettingUpdate() {
            try {
                PluginEntrance.OnModSettingUpdate();
            } catch(Exception e) {
                Log.Error(e);
            }
            
        }

        public override void OnEnterNewWorld() {

            try {
                PluginEntrance.OnEnterNewWorld();
            } catch(Exception e) {
                Log.Error(e);
            }
            
        }

        public override void OnLoadedArchiveData() {

            try {
                PluginEntrance.OnLoadedArchiveData();
            } catch(Exception e) {
                Log.Error(e);
            }
            
        }
    }
}
